package com.health.listener;

import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * topics-通配符模式
 */
@Component
public class Listener5 {

    /**
     * 1号消费者
     */
    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(value = "topic.queue3"),
                    exchange = @Exchange(value = "topic.exchange",
                    type = ExchangeTypes.TOPIC),
                    key = {"name.*"}
            )
    )
    public void listener(String msg){
        System.out.println("111收到消息topics通配符模式>>"+msg);

    }

    /**
     * 2号消费者
     */
    @RabbitListener(
            bindings = @QueueBinding(
                    value = @Queue(value = "topic.queue4"),
                    exchange = @Exchange(value = "topic.exchange"
                    ,type = ExchangeTypes.TOPIC),
                    key = {"merchant.*"}
            )
    )
    public void listener2(String msg){
        System.out.println("222接收到的数据++"+msg);
    }
}
